//
//  MHAccountSecurityViewModel.m
// MiaoCircle
//
//Created by acgera on 2018/4/9.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "MHAccountSecurityViewModel.h"
#import "MHCommonLabelItemViewModel.h"
#import "MHCommonArrowItemViewModel.h"
#import "MHCommonRightButtonViewModel.h"
#import "MHBindViewModel.h"
#import "MHBindSucessViewModel.h"
@implementation MHAccountSecurityViewModel
- (void)initialize{
    [super initialize];
    @weakify(self);
    self.title = @"账号与安全";
    
    MHUser *user = self.services.client.currentUser;
    
    /// 第一组
    MHCommonGroupViewModel *group0 = [MHCommonGroupViewModel groupViewModel];
    /// 微信号
    MHCommonRightButtonViewModel *wechatId = [MHCommonRightButtonViewModel itemViewModelWithTitle:@"微信" icon:@"icon_share_wechat"];
    wechatId.selectionStyle = UITableViewCellSelectionStyleNone;
    wechatId.subtitle = user.wechatId;
    /// 手机号
    MHCommonRightButtonViewModel *phoneNum = [MHCommonRightButtonViewModel itemViewModelWithTitle:@"手机号" icon:@"icon_mine_mobilephone"];
//    phoneNum.centerRightViewName = @"ProfileLockOn_17x17";
//    phoneNum.subtitle = user.bindPhone;
    group0.itemViewModels = @[phoneNum, wechatId];
    self.bindOrModifyPhoneNumberCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
//        [MHHTTPService sharedInstance].currentUser.phone = @"17688823936";
        if ([MHHTTPService sharedInstance].currentUser.bindPhone.length >0) {
            MHBindSucessViewModel *bindSuccessViewModel = [[MHBindSucessViewModel alloc] initWithServices:self.services params:nil];
            [self.services pushViewModel:bindSuccessViewModel  animated:YES];
            
            //        MHBindViewModel *bindViewModel = [[MHBindViewModel alloc] initWithServices:self.services params:nil];
            //        [self.services pushViewModel:bindViewModel  animated:YES];
            return [RACSignal empty];
        }else
        {
            MHBindViewModel *bindViewModel = [[MHBindViewModel alloc] initWithServices:self.services params:nil];
            [self.services pushViewModel:bindViewModel animated:YES];
            return [RACSignal empty];
        }
        
    }];
    
    self.dataSource = @[group0];
    
}
@end
